package cn.cdqf.coupon.dispatch.service.impl;

import cn.cdqf.coupon.common.CommonConstant;
import cn.cdqf.coupon.dispatch.dao.CouponCodeUserMapper;
import cn.cdqf.coupon.dispatch.service.CouponCodeUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@SuppressWarnings("all")
public class CouponCodeUserServiceImpl implements CouponCodeUserService {
    @Autowired
    private CouponCodeUserMapper couponCodeUserMapper;
    @Autowired
    private RedisUtils redisUtils;
    @Override
    @Transactional
    public void batchInsert(List<String> list, String s, String key) {
        //插入的商家+模板+优惠券码
        couponCodeUserMapper.batchInsert(list,s,key);
        //放入redis
        redisUtils.sset(CommonConstant.CouponConstant.REDIS_COUPON_FOR_CODE+key,list.toArray());
        //分布式事务
    }
}
